/**
 * Copyright (c) Software Institute of PKU
 * All rights reserved. 
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 */
package edu.pku.sei.modeler.figures;

import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.RGB;

/**
 * @author zl
 *
 */
public class CommonFigure extends Figure {
	public CommonFigure() {
	}
	protected void paintFigure(Graphics g) {
//		paintShadow(g);
		g.pushState();
		g.setForegroundColor(ColorConstants.white);
		g.fillGradient(getBounds(), true);
		g.popState();
	}
	protected void paintShadow(Graphics g) {
		g.pushState();
		Rectangle rect = getBounds().getCopy().translate(2, 2);
		g.setClip(rect);
		g.setBackgroundColor(ColorConstants.buttonDarker);
		g.fillRectangle(rect);
		g.popState();
	}
	
	public void changeColor(Color color){
		this.setBackgroundColor(color);
	}
	
	public void changeLineColor(Color color) {
		if (color != null)
			this.setForegroundColor(color);
	}
}
